clear all
set more off
set scheme s2color
cd ""

use "sample.dta", clear
gen first_treat = 1 + (mdy(csm_month,csm_day,2020) - mdy(1,10,2020))

* Generate control variables

tab prov_code, gen(prov_code)
forvalues i = 1/24 {
gen provXtime`i' = prov_code`i'*time
gen provXsqtime`i' = prov_code`i'*(time^2)
}

****************
* Subfigure (1)
****************

bootstrap _b[pre5] _b[pre4] _b[pre3] _b[pre2] _b[pre1] _b[tau0] _b[tau1] _b[tau2] _b[tau3] _b[tau4] _b[tau5] _b[tau6] _b[tau7] _b[tau8] _b[tau9] _b[tau10], reps(2000) seed(12345): did_imputation in_confn14 city_code time first_treat if faction == 1, controls(wdsp temp prcp provXtime*) horizons(0/10) autosample pretrends(5) nose

nlcom (_b[_bs_1]-_b[_bs_5]) (_b[_bs_2]-_b[_bs_5]) (_b[_bs_3]-_b[_bs_5]) (_b[_bs_4]-_b[_bs_5]) (_b[_bs_5]-_b[_bs_5]) (_b[_bs_6]) (_b[_bs_7]) (_b[_bs_8]) (_b[_bs_9]) (_b[_bs_10]) (_b[_bs_11]) (_b[_bs_12]) (_b[_bs_13]) (_b[_bs_14]) (_b[_bs_15]) (_b[_bs_16]), post

preserve

do "figureA15_graph.do"
gen faction = 1

tempfile in_confn14
save `in_confn14'

restore

bootstrap _b[pre5] _b[pre4] _b[pre3] _b[pre2] _b[pre1] _b[tau0] _b[tau1] _b[tau2] _b[tau3] _b[tau4] _b[tau5] _b[tau6] _b[tau7] _b[tau8] _b[tau9] _b[tau10], reps(2000) seed(12345): did_imputation in_confn14 city_code time first_treat if faction == 0, controls(wdsp temp prcp provXtime*) horizons(0/10) autosample pretrends(5) nose

nlcom (_b[_bs_1]-_b[_bs_5]) (_b[_bs_2]-_b[_bs_5]) (_b[_bs_3]-_b[_bs_5]) (_b[_bs_4]-_b[_bs_5]) (_b[_bs_5]-_b[_bs_5]) (_b[_bs_6]) (_b[_bs_7]) (_b[_bs_8]) (_b[_bs_9]) (_b[_bs_10]) (_b[_bs_11]) (_b[_bs_12]) (_b[_bs_13]) (_b[_bs_14]) (_b[_bs_15]) (_b[_bs_16]), post

preserve

do "figureA15_graph.do"
gen faction = 0
append using `in_confn14'

replace rel_time = rel_time - 0.1 if faction == 1
replace rel_time = rel_time + 0.1 if faction == 0
#delimit ;
twoway (scatter coef rel_time if faction == 1, sort msymbol(Oh) mcolor(green) pstyle(p4))
       (scatter coef rel_time if faction == 0, msymbol(Th) mcolor(orange) pstyle(p4))
       (rcap ul ll rel_time if faction == 1, lpattern(dash) lcolor(green))
       (rcap ul ll rel_time if faction == 0, lpattern(dash) lcolor(orange) lcolor(*0.9)),
        xtitle("Relative days to Community Stringent Measures") xlabel(-5(1)10, labsize(small) tlength(0.8))
        yline(0 , lcolor(cranberry) lwidth(thin) lpattern(dash))
        xline(-1, lcolor(cranberry) lwidth(thin) lpattern(dash))
        ylabel(, labsize(small) tlength(0.8) grid glwidth(vthin) nogextend)
        legend(order(1 "With informal tie" 2 "Without informal tie") position(8) ring(0) col(1))
        graphregion(fcolor(white) color(white) icolor(white) margin(small)) plotregion(margin(vsmall));
#delimit cr

restore

****************
* Subfigure (2)
****************

bootstrap _b[pre5] _b[pre4] _b[pre3] _b[pre2] _b[pre1] _b[tau0] _b[tau1] _b[tau2] _b[tau3] _b[tau4] _b[tau5] _b[tau6] _b[tau7] _b[tau8] _b[tau9] _b[tau10], reps(2000) seed(12345): did_imputation d_movewithin city_code time first_treat if faction == 1, controls(wdsp temp prcp provXtime* provXsqtime*) horizons(0/10) autosample pretrends(5) nose

nlcom (_b[_bs_1]-_b[_bs_5]) (_b[_bs_2]-_b[_bs_5]) (_b[_bs_3]-_b[_bs_5]) (_b[_bs_4]-_b[_bs_5]) (_b[_bs_5]-_b[_bs_5]) (_b[_bs_6]) (_b[_bs_7]) (_b[_bs_8]) (_b[_bs_9]) (_b[_bs_10]) (_b[_bs_11]) (_b[_bs_12]) (_b[_bs_13]) (_b[_bs_14]) (_b[_bs_15]) (_b[_bs_16]), post

preserve

do "figureA15_graph.do"
gen faction = 1

tempfile d_movewithin
save `d_movewithin'

restore

bootstrap _b[pre5] _b[pre4] _b[pre3] _b[pre2] _b[pre1] _b[tau0] _b[tau1] _b[tau2] _b[tau3] _b[tau4] _b[tau5] _b[tau6] _b[tau7] _b[tau8] _b[tau9] _b[tau10], reps(2000) seed(12345): did_imputation d_movewithin city_code time first_treat if faction == 0, controls(wdsp temp prcp provXtime* provXsqtime*) horizons(0/10) autosample pretrends(5) nose

nlcom (_b[_bs_1]-_b[_bs_5]) (_b[_bs_2]-_b[_bs_5]) (_b[_bs_3]-_b[_bs_5]) (_b[_bs_4]-_b[_bs_5]) (_b[_bs_5]-_b[_bs_5]) (_b[_bs_6]) (_b[_bs_7]) (_b[_bs_8]) (_b[_bs_9]) (_b[_bs_10]) (_b[_bs_11]) (_b[_bs_12]) (_b[_bs_13]) (_b[_bs_14]) (_b[_bs_15]) (_b[_bs_16]), post

preserve

do "figureA15_graph.do"
gen faction = 0
append using `d_movewithin'

replace rel_time = rel_time - 0.1 if faction == 1
replace rel_time = rel_time + 0.1 if faction == 0
#delimit ;
twoway (scatter coef rel_time if faction == 1, sort msymbol(Oh) mcolor(green) pstyle(p4))
       (scatter coef rel_time if faction == 0, msymbol(Th) mcolor(orange) pstyle(p4))
       (rcap ul ll rel_time if faction == 1, lpattern(dash) lcolor(green))
       (rcap ul ll rel_time if faction == 0, lpattern(dash) lcolor(orange) lcolor(*0.9)),
        xtitle("Relative days to Community Stringent Measures") xlabel(-5(1)10, labsize(small) tlength(0.8))
        yline(0 , lcolor(cranberry) lwidth(thin) lpattern(dash))
        xline(-1, lcolor(cranberry) lwidth(thin) lpattern(dash))
        ylabel(, labsize(small) tlength(0.8) grid glwidth(vthin) nogextend)
        legend(order(1 "With informal tie" 2 "Without informal tie") position(8) ring(0) col(1))
        graphregion(fcolor(white) color(white) icolor(white) margin(small)) plotregion(margin(vsmall));
#delimit cr

restore

****************
* Subfigure (3)
****************

bootstrap _b[pre5] _b[pre4] _b[pre3] _b[pre2] _b[pre1] _b[tau0] _b[tau1] _b[tau2] _b[tau3] _b[tau4] _b[tau5] _b[tau6] _b[tau7] _b[tau8] _b[tau9] _b[tau10], reps(2000) seed(12345): did_imputation bdindexS7_std city_code time first_treat if faction == 1, controls(wdsp temp prcp provXtime*) horizons(0/10) autosample pretrends(5) nose

nlcom (_b[_bs_1]-_b[_bs_5]) (_b[_bs_2]-_b[_bs_5]) (_b[_bs_3]-_b[_bs_5]) (_b[_bs_4]-_b[_bs_5]) (_b[_bs_5]-_b[_bs_5]) (_b[_bs_6]) (_b[_bs_7]) (_b[_bs_8]) (_b[_bs_9]) (_b[_bs_10]) (_b[_bs_11]) (_b[_bs_12]) (_b[_bs_13]) (_b[_bs_14]) (_b[_bs_15]) (_b[_bs_16]), post

preserve

do "figureA15_graph.do"
gen faction = 1

tempfile bdindexS7_std
save `bdindexS7_std'

restore

bootstrap _b[pre5] _b[pre4] _b[pre3] _b[pre2] _b[pre1] _b[tau0] _b[tau1] _b[tau2] _b[tau3] _b[tau4] _b[tau5] _b[tau6] _b[tau7] _b[tau8] _b[tau9] _b[tau10], reps(2000) seed(12345): did_imputation bdindexS7_std city_code time first_treat if faction == 0, controls(wdsp temp prcp provXtime*) horizons(0/10) autosample pretrends(5) nose

nlcom (_b[_bs_1]-_b[_bs_5]) (_b[_bs_2]-_b[_bs_5]) (_b[_bs_3]-_b[_bs_5]) (_b[_bs_4]-_b[_bs_5]) (_b[_bs_5]-_b[_bs_5]) (_b[_bs_6]) (_b[_bs_7]) (_b[_bs_8]) (_b[_bs_9]) (_b[_bs_10]) (_b[_bs_11]) (_b[_bs_12]) (_b[_bs_13]) (_b[_bs_14]) (_b[_bs_15]) (_b[_bs_16]), post

preserve

do "figureA15_graph.do"
gen faction = 0
append using `bdindexS7_std'

replace rel_time = rel_time - 0.1 if faction == 1
replace rel_time = rel_time + 0.1 if faction == 0
#delimit ;
twoway (scatter coef rel_time if faction == 1, sort msymbol(Oh) mcolor(green) pstyle(p4))
       (scatter coef rel_time if faction == 0, msymbol(Th) mcolor(orange) pstyle(p4))
       (rcap ul ll rel_time if faction == 1, lpattern(dash) lcolor(green))
       (rcap ul ll rel_time if faction == 0, lpattern(dash) lcolor(orange) lcolor(*0.9)),
        xtitle("Relative days to Community Stringent Measures") xlabel(-5(1)10, labsize(small) tlength(0.8))
        yline(0 , lcolor(cranberry) lwidth(thin) lpattern(dash))
        xline(-1, lcolor(cranberry) lwidth(thin) lpattern(dash))
        ylabel(, labsize(small) tlength(0.8) grid glwidth(vthin) nogextend)
        legend(order(1 "With informal tie" 2 "Without informal tie") position(11) ring(0) col(1))
        graphregion(fcolor(white) color(white) icolor(white) margin(small)) plotregion(margin(vsmall));
#delimit cr

restore
